<script>
	import $H from '@/common/free-lib/request.js';
	export default {
		onLaunch: function() {
			this.Htpp.init_jingmo_login({})
		},
		onShow: function() {
			// #ifdef MP-WEIXIN
			uni.setStorage({
				key: 'platform',
				data: 'MP-WEIXIN'
			});
			// #endif
			// #ifdef APP

			let platform = uni.getSystemInfoSync().platform;
			if (platform === 'ios') {
				uni.setStorage({
					key: 'platform',
					data: 'Ios-App'
				});
			} else if (platform === 'android') {
				uni.setStorage({
					key: 'platform',
					data: 'Android-App'
				});
			} else {
				uni.setStorage({
					key: 'platform',
					data: 'Other-App'
				});
			}
			// #endif
			// #ifdef MP-TOUTIAO
			uni.setStorage({
				key: 'platform',
				data: 'MP-TOUTIAO'
			});
			// #endif
			// #ifdef MP-ALIPAY
			uni.setStorage({
				key: 'platform',
				data: 'MP-ALIPAY'
			});
			// #endif
			// #ifdef MP-BAIDU
			uni.setStorage({
				key: 'platform',
				data: 'MP-BAIDU'
			});
			// #endif
			// #ifdef MP-360
			uni.setStorage({
				key: 'platform',
				data: 'MP-360'
			});
			// #endif
			// #ifdef MP-JD
			uni.setStorage({
				key: 'platform',
				data: 'MP-JD'
			});
			// #endif
			// #ifdef MP-KUAISHOU
			uni.setStorage({
				key: 'platform',
				data: 'MP-KUAISHOU'
			});
			// #endif
			// #ifdef MP-QQ
			uni.setStorage({
				key: 'platform',
				data: 'MP-QQ'
			});
			// #endif
			// #ifdef H5 
			//判断是否是微信公众号
			let ua = navigator.userAgent.toLowerCase();
			if (ua.match(/MicroMessenger/i) == "micromessenger") {
				uni.setStorage({
					key: 'platform',
					data: 'mp-weixin'
				});
			} else {
				uni.setStorage({
					key: 'platform',
					data: 'H5'
				});
			}
			if (!uni.getStorageSync('token')) {
				this.Htpp.h5_jingmo_weixin_login();
			}
			// #endif
			uni.getSystemInfo({
				success: (res) => {
					var system = res.system;
					var uniPlatform = res.uniPlatform;
					var model = res.model;

					var browserName = res.browserName;
					uni.setStorage({
						key: 'system',
						data: system
					});
					uni.setStorage({
						key: 'uniPlatform',
						data: uniPlatform
					});
					uni.setStorage({
						key: 'model',
						data: model
					});
					uni.setStorage({
						key: 'browserName',
						data: browserName
					});
					uni.setStorage({
						key: 'screenHeight',
						data: res.screenHeight
					});
					uni.setStorage({
						key: 'deviceBrand',
						data: res.deviceBrand
					});
					uni.setStorage({
						key: 'brand',
						data: res.brand
					});
					uni.setStorage({
						key: 'appVersion',
						data: res.appVersion
					});
					uni.setStorage({
						key: 'deviceModel',
						data: res.deviceModel
					});
					uni.setStorage({
						key: 'model',
						data: res.model
					});
					uni.setStorage({
						key: 'osAndroidAPILevel',
						data: res.osAndroidAPILevel
					});
					uni.setStorage({
						key: 'romName',
						data: res.romName
					});
					uni.setStorage({
						key: 'romVersion',
						data: res.romVersion
					});
					uni.setStorage({
						key: 'system',
						data: res.system
					});
				}
			})
		},
		onHide: function() {
			console.log('App Hide')
		},
	}
</script>

<style lang="scss">
	/*每个页面公共css */
	@import "./static/mi.scss";
	@import "./static/iconfont.css";
</style>